<textarea id="trumbowyg"> <%= content %> </textarea>

<script type="text/javascript">
  $(document).ready(function() {
    $('#trumbowyg').trumbowyg({
      svgPath: "https://cdnjs.cloudflare.com/ajax/libs/Trumbowyg/2.20.0/ui/icons.svg",
      btnsDef: {
        image: {
          dropdown: ['insertImage', 'upload'],
          ico: 'insertImage'
        }
      },
      btns: [
        ['viewHTML'],
        ['undo', 'redo'],
        ['formatting'],
        ['fontfamily'],
        ['strong', 'em', 'foreColor', 'backColor', 'del'],
        ['superscript', 'subscript'],
        ['link'],
        ['image'],
        ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
        ['unorderedList', 'orderedList'],
        ['horizontalRule'],
        ['removeformat'],
        ['fullscreen']
      ],
      plugins: {
        upload: {
          serverPath: 'https://api.imgur.com/3/image',
          fileFieldName: 'image',
          headers: {
            'Authorization': 'Client-ID 9a33b3b370f1054'
          },
          urlPropertyName: 'data.link',
        },
        resizimg: {
          minSize: 64,
          step: 16,
        }
      }
    });
  });
  $.fn.cleanHtml = function () {
      var html = $('#trumbowyg').trumbowyg('html');
      return html && html.replace(/(<br>|\s|<div><br><\/div>|&nbsp;)*$/, '');
    };
</script>
